package com.xyt.imei.core;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

/**
 * 
 * 数据库映射自动生成工�?
 * 
 * @author wulinfeng
 * @date 2017-11-08
 *
 */
public class MybatisGeneratorExecution {

	public static void generator(){  
        
        List<String> warnings=new ArrayList<String>();  
        try {  
        String configFilePath = Thread.currentThread().getContextClassLoader().getResource("mybatis-generator.xml").getPath();
        System.out.println(configFilePath);
        File configFile=new File(configFilePath);  
        ConfigurationParser cp=new ConfigurationParser(warnings);  
        Configuration config=cp.parseConfiguration(configFile);  
        DefaultShellCallback dsc=new DefaultShellCallback(true);  
        MyBatisGenerator mg=new MyBatisGenerator(config, dsc, warnings);  
        mg.generate(null);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
          
    }  
  
    public static void main(String[] args) {  
        MybatisGeneratorExecution.generator();  
        System.out.println("done!");  
    }  

}
